package jpm.trade;

import static jpm.common.AssertUtils.ensure;
import static jpm.common.AssertUtils.ensureNotNull;
import jpm.trade.TradeHelper.Operation;

public final class Trade {

	// this class is immutable

	public Trade(int tradeId, int tradeVersion, String security,
			int quantity, boolean buy, String accountNo, Operation operation) {

		ensure(tradeId != 0, "tradeId is 0");
		ensure(tradeVersion != 0, "tradeVersion is 0");
		ensureNotNull(security, "security is null");
		ensureNotNull(accountNo, "accountNo is null");
		ensureNotNull(operation, "operation is null");

		this.tradeId = tradeId;
		this.tradeVersion = tradeVersion;
		this.security = security;
		this.quantity = quantity;
		this.buy = buy;
		this.accountNo = accountNo;
		this.operation = operation;
	}

	private final int tradeId;
	private final int tradeVersion;
	private final String security;
	private final int quantity;
	private final boolean buy;
	private final String accountNo;
	private final Operation operation;

	public int getTradeId() {
		return tradeId;
	}

	public int getTradeVersion() {
		return tradeVersion;
	}

	public String getSecurity() {
		return security;
	}

	public int getQuantity() {
		return quantity;
	}

	public boolean isBuy() {
		return buy;
	}

	public String getAccountNo() {
		return accountNo;
	}

	public Operation getOperation() {
		return operation;
	}

//	@Override
//	public String toString() {
//		return tradeId + "|" + tradeVersion + "|" + security + "|" + quantity + "|"
//				+ (isBuy() ? "BUY" : "SELL") + "|" + accountNo + "|"
//				+ operation;
//	}
}
